from django.urls import path, include, re_path

from api import views

# 帮我自动生成路由
from rest_framework import routers
router = routers.DefaultRouter()
# 返回的前缀为rt
router.register(r'rt',views.Pager4View)


urlpatterns = [
    re_path(r'^(?P<version>[v1|v2]+)/users$', views.UsersView.as_view()),
    re_path(r'^(?P<version>[v1|v2]+)/parser$', views.ParserView.as_view()),
    re_path(r'^(?P<version>[v1|v2]+)/role$', views.RoleView.as_view()),
    re_path(r'^(?P<version>[v1|v2]+)/user$', views.UserInfoView.as_view()),
    re_path(r'^(?P<version>[v1|v2]+)/pager1$', views.Pager1View.as_view()),
    re_path(r'^(?P<version>[v1|v2]+)/lan$', views.Pager2View.as_view()),
    # 继承GenericViewSet后，转折点，直接要让我传一个字典，get请求不是执行get接口，而是执行我指定的list接口
    re_path(r'^(?P<version>[v1|v2]+)/yue$', views.Pager3View.as_view({'get':'list'})),
    re_path(r'^(?P<version>[v1|v2]+)/chuan$', views.Pager4View.as_view({'get':'list','post':'create'})),
    re_path(r'^(?P<version>[v1|v2]+)/(?P<pk>\d+)$', views.Pager5View.as_view({'get':'retrieve','delete':'destroy','put':'update','patch':'partial_update'})),
    # 渲染器
    re_path(r'^(?P<version>[v1|v2]+)/lanyue$', views.LanView.as_view()),

    re_path(r'^(?P<version>[v1|v2]+)$',include(router.urls)),
]
